$(function() {
	$('#search').click(function(){
		$.ajax({
			url : DI.biFtpFileList,
			type : 'POST',
			data : {dirPath : $('#dirPath').val()},
			success:function(json) {
				var data = $.parseJSON(json);
				if (data != null && data.retFlag == '1') {
					var len = data.data.length;
					var rows = data.data;
					var htmlStr = '';
					for (var i = 0; i < len; i++) {
						htmlStr += ('<tr><td>' + rows[i] + '</td><td><a target="_blank" href="'+ DI.biFileDownload 
								+ rows[i] + '&&dirPath=' + $('#dirPath').val() + '">下载</a>');
					}
					$('#searchResult').html(htmlStr);
				} else {
					alert('查询失败');
				}
			}
		});
	});
	$('#upFile').click(function(){
		$('#file_form').ajaxSubmit({
			type: "post",
	        dataType: "json",
	        url: DI.biFileUpload,
	        success: function(json) {
	        	var data = $.parseJSON(json);
	        	if (data != null && data.retFlag == '1') {
	        		alert("上传成功");
	        	} else {
	        		alert("上传失败");
	        	}
	        },
	        error: function(XMLHttpRequest, textStatus, errorThrown) {
	        	PLATFORM.showTips("error", "服务异常,请稍后再试");
	            console.log("ajax error");
	            console.log(XMLHttpRequest);
	        }
		});
	});
	
});